﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace PopQuiz
{
  class Program
  {
    static void Main(string[] args)
    {
      string where;
      DateTime when;
      int length;

      Console.Write("Where would you like to go?: ");
      where = Console.ReadLine();

      Console.Write("When would you like to go?: ");
      when = DateTime.Parse(Console.ReadLine());

      Console.Write("How many days will you stay?: ");
      length = int.Parse(Console.ReadLine());

      Vacation yourVacation = new Vacation(where, when, length);
      ShowVacation(yourVacation);

      Console.Write("What is the cost per day?: $");
      decimal costPerDay = decimal.Parse(Console.ReadLine());
      decimal totalCost = yourVacation.CalculateCost(costPerDay);

      Console.WriteLine("Would you like to book this vacation for {0:c}? (Y/N)", 
                                        totalCost);

      if (Console.ReadLine().ToUpper() == "Y")
      {
        PrintVacation(yourVacation, totalCost);
        Console.WriteLine("Vacation printed.");
      }
      else
      {
        Console.WriteLine("Vacation cancelled");
      }


      Console.ReadKey();
    }

    static void ShowVacation(Vacation vacation)
    {
      Console.WriteLine("\n******** Here's Your Vacation! ******");
      Console.WriteLine("Destination {0}", vacation.DestinationName);
      Console.WriteLine("From {0:d} to {1:d}\n", vacation.StartDate, vacation.EndDate);
    }

    static void PrintVacation(Vacation vaction, decimal cost)
    {
      XElement xml = new XElement("vacation",
                                     new XElement("destination", vaction.DestinationName),
                                     new XElement("start-date", vaction.StartDate),
                                     new XElement("end-date", vaction.EndDate),
                                     new XElement("price", cost));
      xml.Save("C:\\vacation.xml");
    }
  }
}
